package cn.edu.zafu.bigdata.x.zhouyuyan.work7;

public class ArrayIndexOutOfBoundsExceptionHandler {
    public static int getElement(int[] arr, int index){
        return arr[index];
    }

    public static void main(String[] args) {
        try{
            int[] array = {1,2,3,4,5};
            int index = 5;
            int element = getElement(array,index);
            System.out.println("数组中的元素是:"+element);
        }catch (ArrayIndexOutOfBoundsException e){
            System.err.println("错误:"+e.getMessage());
        }
    }
}
